package com.ruoyi.inventory.service.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.ruoyi.common.utils.SeqNumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.StocktakeMapper;
import com.ruoyi.inventory.domain.Stocktake;
import com.ruoyi.inventory.service.IStocktakeService;

/**
 * 库存盘点记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@Service
public class StocktakeServiceImpl implements IStocktakeService 
{
    @Autowired
    private StocktakeMapper stocktakeMapper;

    /**
     * 查询库存盘点记录
     * 
     * @param id 库存盘点记录主键
     * @return 库存盘点记录
     */
    @Override
    public Stocktake selectStocktakeById(Long id)
    {
        return stocktakeMapper.selectStocktakeById(id);
    }

    /**
     * 查询库存盘点记录列表
     * 
     * @param stocktake 库存盘点记录
     * @return 库存盘点记录
     */
    @Override
    public List<Stocktake> selectStocktakeList(Stocktake stocktake)
    {
        return stocktakeMapper.selectStocktakeList(stocktake);
    }

    /**
     * 新增库存盘点记录
     * 
     * @param stocktake 库存盘点记录
     * @return 结果
     */
    @Override
    public int insertStocktake(Stocktake stocktake)
    {
        stocktake.setInventorySheetNo(SeqNumberUtils.getKCPDNumber());
        return stocktakeMapper.insertStocktake(stocktake);
    }

    /**
     * 修改库存盘点记录
     * 
     * @param stocktake 库存盘点记录
     * @return 结果
     */
    @Override
    public int updateStocktake(Stocktake stocktake)
    {
        stocktake.setUpdatedTime(LocalDateTime.now());
        return stocktakeMapper.updateStocktake(stocktake);
    }

    /**
     * 批量删除库存盘点记录
     * 
     * @param ids 需要删除的库存盘点记录主键
     * @return 结果
     */
    @Override
    public int deleteStocktakeByIds(Long[] ids)
    {
        return stocktakeMapper.deleteStocktakeByIds(ids);
    }

    /**
     * 删除库存盘点记录信息
     * 
     * @param id 库存盘点记录主键
     * @return 结果
     */
    @Override
    public int deleteStocktakeById(Long id)
    {
        return stocktakeMapper.deleteStocktakeById(id);
    }
}
